//package cn.handong.tool.spring_aop;
//
//import com.alibaba.fastjson.JSONObject;
//import org.apache.logging.log4j.util.Strings;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.Ordered;
//import org.springframework.core.annotation.Order;
//import org.springframework.data.redis.cache.RedisCache;
//import org.springframework.stereotype.Component;
//
//import java.util.Objects;
//
///**
// * @Author: CiXingrui
// * @Create: 2021/9/28 4:31 下午
// * <p>
// * 幂等切面，
// */
//@Component
//@Aspect
//@Order(Ordered.LOWEST_PRECEDENCE)
//public class IdempotentAspect {
//
////    @Autowired
////    private RedisCache redisCache;
//
//    @Pointcut("@annotation(cn.handong.tool.spring_aop.Idempotent)")
//    public void check() {
//
//    }
//
////    @Around("@annotation(Idempotent)")
////    public Object checkProcess(ProceedingJoinPoint jp) throws Throwable {
////
////        String methodName = jp.getSignature().getName();
////        //获取参数值
////        Object[] args = jp.getArgs();
////        String argsString = Objects.isNull(args) ? Strings.EMPTY : JSONObject.toJSONString(args[0]).substring(0, 16);
////
////        String redisKey = Utils.appendString(argsString, methodName);
////
////        RedisLock operationLocks = redisCache.createLock(RedisKey.getIdempotentLock(redisKey));
////
////        try {
////            //获取锁
////            boolean flag = operationLocks.acquireLock(Consts.RedisLockParam.OP_PROCESS_TIME);
////
////            return flag ? jp.proceed() : Protos.createResponse(ResponseCode.REDIS_LOCK_ERROR);
////        } finally {
////            try {
////                operationLocks.releaseLock();
////            } catch (Exception e) {
////                LogUtils.ERROR.error("idempotentLockForParams release Lock is error : ", e);
////            }
////        }
////    }
//
//}